﻿function backspace()
{
    if (confirm('是否确认退出登录？')) {
        alert("已退出登录，请重新登录！");
        var lable = document.getElementById("welcome");
        lable.innerText = "请您先进行登录，暂时无法使用♥";
    }
}
function getTime()
{
    var now = new Date();
    var y = now.getFullYear();
    var m = now.getMonth() + 1;
    var d = now.getDate();
    var h = now.getHours();
    var mm = now.getMinutes();
    var ss = now.getSeconds();
    var e = now.getDay()+"";
    var ds = y + "年" + m + "月" + d + "日" + h + "时" + mm + "分" + ss + "秒 星期" + e;
    document.getElementById("date").innerHTML = ds;
    setTimeout("getTime()",1000);
}
function Add() {
    var res = 0;
    if (res == 0) {
        //菜品名称验证
        var hn = document.tbAdd.txtmname.value;
        var n = /^([\u2E80-\u9FFF]){1,8}$/;
        if (hn == 0)
        {
            alert("请设置菜品名称");
            
        }
        else if (!n.test(hn)) {
            alert("菜品名称输入有误!");
            document.tbAdd.txtmname.focus;
            res = 0;
        }
        if (n.test(hn)) {
            res = res + 1;
        }
        //价格验证
        var price = document.tbAdd.txtprice.value;
        var p = /^.*(?=.{1,}).*$/;
        if (!p.test(price)) {
            alert("价格有误");
            document.tbAdd.txtprice.focus;
            res = 0;
        }
        if (p.test(price)) {
            res = res + 1;
        }
        //折扣验证
        var price = document.tbAdd.txtdiscount.value;
        var p = /^.*(?=.{1,}).*$/;
        if (!p.test(price)) {
            alert("请设置折扣");
            document.tbAdd.txtdiscount.focus;
            res = 0;
        }
        if (p.test(price)) {
            res = res + 1;
        }
        //上传文件验证
        var hp = document.tbAdd.fileimg.value;
        if (hp == 0) {
            alert("请上传英雄图片！");
            res = 0;
        }
        if (hp) {
            res = res + 1;
        }
        //详情验证
        var tc = document.tbAdd.txtdetail.value;
        if (!tc) {
            alert("请填写详情！");
            res = 0;
        }
        if (tc) {
            res = res + 1;
        }
    }
    if (res == 5) {
        alert("添加成功！");
    }
}
function Delete()
{
    var d = confirm('确认删除吗？');
    if (d == true)
    {
        alert("删除成功！");
    }
}